home *** CD-ROM | disk | FTP | other *** search
/ Aminet 39 / Aminet 39 (2000)(Schatztruhe)[!][Oct 2000].iso / Aminet / game / shoot / Orbit_src.lha / Orbit / source / waypoint.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-07-04  |  1.9 KB  |  109 lines

  1. /*
  2.     Amiga port by Oliver Gantert
  3.  
  4.     28.04.2000 - fixed some compiler warnings
  5. */
  6. /*
  7.  
  8. ORBIT, a freeware space combat simulator
  9. Copyright (C) 1999  Steve Belczyk <steve1@genesis.nred.ma.us>
  10.  
  11. This program is free software; you can redistribute it and/or
  12. modify it under the terms of the GNU General Public License
  13. as published by the Free Software Foundation; either version 2
  14. of the License, or (at your option) any later version.
  15.  
  16. This program is distributed in the hope that it will be useful,
  17. but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  19. GNU General Public License for more details.
  20.  
  21. You should have received a copy of the GNU General Public License
  22. along with this program; if not, write to the Free Software
  23. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  24.  
  25. */
  26.  
  27. #include "orbit.h"
  28.  
  29. /*
  30.  *  Routines to implement waypoints
  31.  */
  32.  
  33. void InitWaypoints()
  34. /*
  35.  *  Reset waypoints
  36.  */
  37. {
  38.   int w;
  39.  
  40.   nwaypoints = 0;
  41.   player.waypoint = (-1);
  42.  
  43.   for (w=0; w<NWAYPOINTS; w++)
  44.   {
  45.     waypoint[w].pos[0] = 0.0;
  46.     waypoint[w].pos[1] = 0.0;
  47.     waypoint[w].pos[2] = 0.0;
  48.   }
  49. }
  50.  
  51. void AddWaypoint (double *v)
  52. /*
  53.  *  Define a new waypoint
  54.  */
  55. {
  56.   if (nwaypoints == NWAYPOINTS)
  57.   {
  58.     Log ("AddWaypoint: Too many waypoints.  Increase NWAYPOINTS in orbit.h");
  59.     return;
  60.   }
  61.  
  62.   Vset (waypoint[nwaypoints].pos, v);
  63.   nwaypoints++;
  64. }
  65.  
  66. void NextWaypoint()
  67. /*
  68.  *  Advance to next waypoint
  69.  */
  70. {
  71.   if (nwaypoints == 0) return;
  72.  
  73.   if (player.waypoint == (-1))
  74.   {
  75.     player.waypoint = 0;
  76.     return;
  77.   }
  78.  
  79.   player.waypoint++;
  80.  
  81.   if (player.waypoint == nwaypoints)
  82.   {
  83.     player.waypoint = (-1);
  84.     return;
  85.   }
  86. }
  87.  
  88. void PrevWaypoint()
  89. /*
  90.  *  Back to previous waypoint
  91.  */
  92. {
  93.   if (nwaypoints == 0) return;
  94.  
  95.   if (player.waypoint == 0)
  96.   {
  97.     player.waypoint = (-1);
  98.     return;
  99.   }
  100.  
  101.   if (player.waypoint == (-1))
  102.   {
  103.     player.waypoint = nwaypoints - 1;
  104.     return;
  105.   }
  106.  
  107.   player.waypoint--;
  108. }
  109.